﻿using Framework.Domain.Enum;
using Framework.Infrastructure;
using Framework.MVC.Infrastructure;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Framework.MVC.Controllers
{
    public class LogController : BaseController
    {
        /// <summary>
        /// 获取日志分类
        /// </summary>
        /// <param name="type">日志分类：1、一级分类 2、二级分类 3、三级分类</param>
        /// <param name="enumName">枚举名称</param>
        /// <returns></returns>
        [HttpGet]
        public JsonResult GetLogType(int type, string enumName = "一级分类")
        {
            Dictionary<string, Dictionary<int, string>> dic;
            switch (type)
            {
                case 1:
                default:
                    dic = Common.GetEnumDescriptions(typeof(CategoryEnum));
                    break;
                case 2:
                    dic = Common.GetEnumDescriptions(typeof(ActionEnum), enumName);
                    break;
                case 3:
                    dic = Common.GetEnumDescriptions(typeof(OperateEnum), enumName);
                    break;
            }
            if (dic.Count == 0)
                return Json(new Dictionary<int, string> { }.ToArray());
            else
                return Json(dic[enumName].ToArray());
        }


    }
}